package gsm.cable.client.view;

import gsm.cable.client.DefaultConstants;
import gsm.cable.client.css.StylesheetConstants;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;

public class FooterWidget extends HorizontalPanel {

	private Image organizationLogo;

	public FooterWidget() {
		setHeight(DefaultConstants.FOOTER_HEIGHT + "px");
		setStyleName(StylesheetConstants.APP_FOOTER_PANEL);
	}

	public void setCenterText() {
		HTML centerHtml = new HTML("Copyright &copy; gms.com. All rights reserved. Design by GMS");
		centerHtml.addStyleName(StylesheetConstants.APP_FOOTER_CENTER_TEXT);
		add(centerHtml);
	}

	public void addLink(String url, String name) {
		if (url != null && url.trim().length() > 0) {
			Anchor link = new Anchor();
			link.setStyleName(StylesheetConstants.APP_FOOTER_LINK);
			link.setHref(url);
			link.setHTML(name);
			add(link);
			link.getElement().getParentElement().getStyle().setWidth((name.length() * 7), Unit.PX);
		}
	}

	public void setOrganizationLogo(String imageUrl) {
		if (organizationLogo == null) {
			organizationLogo = new Image();
			organizationLogo.setPixelSize(DefaultConstants.ORGANIZATION_LOGO_WIDTH, DefaultConstants.FOOTER_HEIGHT);
			add(organizationLogo);
		}
		if (imageUrl != null && imageUrl.trim().length() > 0) {
			organizationLogo.setStyleName("");
			organizationLogo.setUrl(imageUrl);
		}

	}

	public void addSaperator() {
		HTML saperator = new HTML(" | ");
		add(saperator);
	}
}
